# # from py2neo import Node, Relationship
# #
# # a = Node('Person', name='Alice')
# # b = Node('Person', name='Bob')
# # r = Relationship(a, 'KNOWS', b)
# # print(a, b, r)
# #
# # a['age'] = 20
# # b['age'] = 21
# # r['time'] = '2017/08/31'
# # print(a, b, r)
# #
# # # a.setdefault('location', '北京')
# # # print(a)
# #
# # a['location'] = '上海'
# # a.setdefault('location', '北京')
# # print(a)
#
# # from py2neo import Node, Relationship
# #
# # a = Node('Person', name='Alice')
# # b = Node('Person', name='Bob')
# # r = Relationship(a, 'KNOWS', b)
# # s = a | b | r
# # print(s)
#
# import functools
#
# def minus(a, b):
#     return a - b
#
# print(minus(4, 2))
# plus3 = functools.partial(minus, b=3)
# plus5 = functools.partial(minus, b=5)
# print(plus3(4))
# print(plus3(7))
# print(plus5(10))



from py2neo import Graph
# graph_1 = Graph()
# graph_2 = Graph(host="localhost")
# graph_3 = Graph("http://localhost:7474/db/data/")


# '''
# ``auth``        A 2-tuple of (user, password)                  tuple           ``('neo4j', 'password')``
# ``host``        Database server host name                      str             ``'localhost'``
# ``password``    Password to use for authentication             str             ``'password'``
# ``port``        Database server port                           int             ``7687``
# ``scheme``      Use a specific URI scheme                      str             ``'bolt'``
# ``secure``      Use a secure connection (TLS)                  bool            ``False``
# ``user``        User to authenticate as                        str             ``'neo4j'``
# ``user_agent``
#
# '''
# graph1 = Graph('http://116.62.163.101:7474')

# from py2neo import Node, Relationship, Graph
#
# a = Node('Person', name='Alice')
# b = Node('Person', name='Bob')
# r = Relationship(a, 'KNOWS', b)
# s = a | b | r
# graph = Graph(scheme='http', host='116.62.163.101', port=7474, user='neo4j', password='Pw123456!')
# graph.create(s)
#
# from py2neo import Graph, Node, Relationship
#
# graph = Graph(password='123456')
# a = Node('Person', name='Alice')
# graph.create(a)
# b = Node('Person', name='Bob')
# ab = Relationship(a, 'KNOWS', b)
# graph.create(ab)

# from py2neo import Graph, Node, Relationship
#
# graph = Graph(scheme='http', host='116.62.163.101', port=7474, user='neo4j', password='Pw123456!')
#
# a = Node('Person', name='Alice')
# graph.create(a)
# b = Node('Person', name='Bob')
# ab = Relationship(a, 'KNOWS', b)
# graph.create(ab)

from py2neo import Graph

graph = Graph(scheme='http', host='116.62.163.101', port=7474, user='neo4j', password='Pw123456!')
# print(graph)
# data = graph.match('MATCH (p:Person) return p')
# print(data)
# for rel in graph.match((alice, ), r_type="FRIEND"):
#     print(rel.end_node["name"])

# from py2neo import Graph
# print(graph.run("UNWIND range(1, 3) AS n RETURN n, n * n as n_sq").to_table())

from py2neo import Graph

# node = graph.find_one(label='Person')
# print(node)
# relationship = graph.match_one(r_type='KNOWS')
# print(relationship)


from py2neo import Graph

# data = graph.run('MATCH (p:Person) RETURN p LIMIT 5')
# print(list(data))

from py2neo import Graph, Node, Relationship

# a = Node('Person', name='Alice', age=21, location='广州')
# b = Node('Person', name='Bob', age=22, location='上海')
# c = Node('Person', name='Mike', age=21, location='北京')
# r1 = Relationship(a, 'KNOWS', b)
# r2 = Relationship(b, 'KNOWS', c)
# graph.create(a)
# graph.create(r1)
# graph.create(r2)

# from py2neo import Graph, NodeSelector
#
# graph = Graph(password='123456')
# selector = NodeSelector(graph)
# persons = selector.select('Person', age=21)
# print(list(persons))

from py2neo import Graph
from py2neo.ogm import GraphObject, Property



class Person(GraphObject):
    __primarykey__ = 'name'

    name = Property()
    age = Property()
    location = Property()

person = Person.run(graph).where(age=21).first()
print(person)
print(person.name)
print(person.age)